package co.edu.unal.geditor.controller.action.tool;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;

import co.edu.unal.geditor.controller.App;
import co.edu.unal.geditor.view.tools.Tool;

public abstract class BaseToolAction extends AbstractAction
{
	private static final long serialVersionUID = 1L;

	protected abstract Tool getTool();

	public BaseToolAction( String text, String icon, String desc, Integer mnemonic )
	{
		super( text );

		putValue( SHORT_DESCRIPTION, desc );
		putValue( MNEMONIC_KEY, mnemonic );
		putValue( SMALL_ICON, new ImageIcon( getClass().getClassLoader().getResource( BASE + icon ) ) );
	}

	public void actionPerformed( ActionEvent e )
	{
		App app = App.getInstance();
		app.setActiveTool( getTool() );
	}

	private static final String BASE = "co/edu/unal/geditor/resources/";
}
